import { getOneArticleLiked, getOnePagePv } from './service';
import style from './index.less';
import React, { Fragment, useState, useEffect } from 'react';
import IconFont from '@/components/Icon';

const Count = ({ id }) => {
  const [pv, setPv] = useState(0);
  const user_id = localStorage.getItem('user_id');
  const [liked, setLiked] = useState(0);
  const fetchData = async () => {
    getOnePagePv({ id }).then(res => {
      setPv(res.data.PV);
    });
    getOneArticleLiked({ article_id: id, operateuser_id: user_id }).then(res => {
      setLiked(res.data[0].count);
    });
  };
  useEffect(() => {
    fetchData();
  }, []);
  return (
    <>
      <div className={style.icon}>
        <IconFont type="icona-dianzan3" style={{ fontSize: '15px' }} />  {liked}
      </div>
      <div className={style.icon}>
        <IconFont type="iconliulan" style={{ fontSize: '15px' }} /> {pv}
       
      </div>
    </>
  );
};
export default Count;
